package com.chapter.sample.jvm.gc;

import java.util.concurrent.TimeUnit;

/**
 * 强引用；即使内存不够也不回收
 */
public class StrongReferenceTest {
    public static void main(String[] args) {
        StringBuffer str = new StringBuffer();
        StringBuffer str1 = str;

        str = null;
        System.gc();

        try {
            TimeUnit.SECONDS.sleep(3);
        }catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(str1);
    }
}
